<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="gdufs.stat.service.FwtjQuery" %>
<%@page import="java.util.*" %>
<%@page import="java.sql.Date" %>
<%@page import="java.text.*" %>
<%@page import="org.apache.commons.lang.StringUtils" %>
<html>
<head>
<%@include file="/inc/head.jsp" %>
<%
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application); 
FwtjQuery fwtjQuery = (FwtjQuery)context.getBean("fwtjQuery");
%>
<%
	DecimalFormat dFormat = new DecimalFormat("##.##%");
	String starttime = "";
	String endtime = "";
	String metier = "";
	starttime = request.getParameter("starttime");
	endtime = request.getParameter("endtime");
	metier = request.getParameter("metier");
	List<Map> typeVisitStatics = new ArrayList<Map>();
	
	String typeStatics = fwtjQuery.getTypeStatics(starttime,endtime);
	typeVisitStatics = fwtjQuery.getTypeStaticsDetail(starttime,endtime);
	
	starttime = StringUtils.trimToEmpty(starttime);
	endtime = StringUtils.trimToEmpty(endtime);
	
%>

<title>按身份统计登录情况</title>
<script type="text/javascript" src="../FusionCharts/FusionCharts.js"></script>
<link href="../css/calendar.css" rel="stylesheet" type="text/css">
<script language=javascript src="../javascripts/calendar/calendar.js"></script>
<script language=javascript src="../javascripts/calendar/calendar-zh.js"></script>
<script language=javascript src="../javascripts/calendar/calendar-setup.js"></script>

<script type="text/javascript">
function doReset(){
	document.getElementById("starttime").value = "";
	document.getElementById("endtime").value = "";
}
</script>
</head>
<body style="padding: 5px;">
<!-- 查询框 -->
	<form action="typeStatics.jsp" method="post">
	
	<table width="100%" border="0" cellpadding="0" cellspacing="0" style="padding:5px;border:1px solid #aaaaaa;background-color: #efefef">
		<tr>
			<td align="right">开始时间:</td>
			<td><input type="text" id="starttime" name="starttime" value="<%=starttime %>"
				style="background-color: white;">&nbsp;<input name="" type="image" src="../images/iconDate.gif" id="_starttime"></td>
			<td align="right">结束时间:</td>
			<td><input type="text" id="endtime" name="endtime" value="<%=endtime %>"
				style="background-color: white;">&nbsp;<input name="" type="image" src="../images/iconDate.gif" id="_endtime"></td>
			<td><input type="submit" value="提交" />&nbsp;<input type="button" onclick="doReset();"
				value="重置"></td>
		</tr>
	</table>
		
	
		<div>
			<div id="chartContainer">FusionCharts will load here!</div>
			<script type="text/javascript">
						var myChart = new FusionCharts( "../FusionCharts/Column3D.swf","myChartId", "100%", "500", "0", "1" );    
						myChart.setXMLData("<%=typeStatics%>"); 
						myChart.render("chartContainer");          
					</script>
		</div>
	
	<!-- 列表统计 -->
		<table cellpadding="3" cellspacing="0" width="100%" border="1" style="border:1px solid #aaaaaa;border-collapse: collapse;margin-top: 5px;" bordercolor="#aaaaaa">
				<tr >
					<th width="30%">身份类别</th>
					<th width="20%">访问人数</th>
					<th width="20%">访问次数</th>
					<th width="30%">类别次数占总次数百分比</th>
				</tr>
				<% 
					String metierName = "";
					for(int i = 0 ; i < typeVisitStatics.size() ; i++){
						Map staticsMap = (Map)typeVisitStatics.get(i);
						int type = (Integer)staticsMap.get("metier");
						if(1 == type){
							metierName = "教师";
						}else if(2 == type){
							metierName = "研究生";
						}else if(3 == type){
							metierName = "本科生";
						}else{
							metierName = "所有";
						}
						int visitAccount = (Integer)staticsMap.get("visitAccount");
						int userAccount = (Integer)staticsMap.get("userAccount");
						double percentage = (Double)staticsMap.get("percentage");
				%>
					<tr>
						<td align="center"><%=metierName %></td>
						<td align="center"><%=userAccount %></td>
						<td align="center"><%=visitAccount %></td>
						<td align="center"><%=dFormat.format(percentage) %></td>
					</tr>
				<% 
					}
				%>
			</table>
	</form>
<script type=text/javascript>
		Calendar.setup(
		{
			inputField  : "starttime",	// 接受输入值的控件
			button      : "_starttime",	// 调用日历的控件
			ifFormat    : "%Y-%m-%d"	// 日期格式
		}		
		);
		
		Calendar.setup(
		{
			inputField  : "endtime",	// 接受输入值的控件
			button      : "_endtime",	// 调用日历的控件
			ifFormat    : "%Y-%m-%d"	// 日期格式
		}		
		);
				
</script>
</body>
</html>